<!------------------- 头部CSS部分 start-------------------------------------------------------------------------------->
{include file="Public/head"/}
<!------------------- 头部CSS部分 end---------------------------------------------------------------------------------->

<body class="no-skin">

<!---------------------头部消息栏,用户栏 start--------------------------------------------------------------------->
{include file="Public/header"/}
<!---------------------头部消息栏,用户栏 end----------------------------------------------------------------------->

<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <!-------------------------菜单栏 start-------------------------------------------------------------------->
    {include file="Public/menu"/}
    <!-------------------------菜单栏 end---------------------------------------------------------------------->

    <div class="main-content">
        <div class="main-content-inner">

            <!-------------------------------路径导航 面包屑 start--------------------------------------------->
            {include file="Public/breadcrumbs"/}
            <!-------------------------------路径导航 面包屑 end----------------------------------------------->

            <div class="page-content">

                <!-----------------------------右侧设置 页面提示消息 start------------------------------------->
                {include file="Public/set"/}
                <!-----------------------------右侧设置 页面提示消息 end--------------------------------------->

                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" id="form" name="form" action="{:url('Group/update')}" method="post">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 用户组名 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="name" id="name" placeholder="用户组名"
                                           class="col-xs-10 col-sm-5" value="{$group.name}">

                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">用户组名称，不能为空。</span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 是否启用 </label>
                                <div class="control-label no-padding-left col-sm-1">
                                    <div class="radio">
                                        <label>
                                            <input name="status" type="radio" class="ace" value="1" checked="checked" {if condition="$group.status eq 1"}checked="checked"{/if} />
                                            <span class="lbl">启用</span>
                                        </label>
                                        <label>
                                            <input name="status" type="radio" class="ace" value="2" {if condition="$group.status eq 2"}checked="checked"{/if} />
                                            <span class="lbl">禁用</span>
                                        </label>
                                    </div>
                                </div>
                                <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle"></span>
                                        </span>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                    <label class="col-sm-1 control-label no-padding-right" for="form-field-1">
                                        权限选择 </label>
                                    <div class="col-sm-9">
                                        <div class="col-sm-10">
                                            {volist name="rule" id="v"}
                                                <div class="row">
                                                    <div class="widget-box">
                                                        <div class="widget-header">
                                                            <h4 class="widget-title">
                                                                <label>
                                                                    <input name="rules[]" class="ace ace-checkbox-2 father"
                                                                    <?php if($group){ if(in_array($v['id'],$group['rules'])){echo 'checked="checked"';}} ?>
                                                                    type="checkbox" value="{$v.id}"/>
                                                                    <span class="lbl"> {$v.name}</span>
                                                                </label>
                                                            </h4>
                                                            <div class="widget-toolbar">
                                                                {notempty name="v.children"}
                                                                    <a href="#" data-action="collapse">
                                                                        <i class="ace-icon fa fa-chevron-up"></i>
                                                                    </a>
                                                                {/notempty}
                                                            </div>
                                                        </div>
                                                        {notempty name="v.children"}
                                                            <div class="widget-body">
                                                                <div class="widget-main row">
                                                                    {volist name="v.children" id="vv"}
                                                                        <label class="col-xs-2" style="width:160px;">
                                                                            <input name="rules[]" class="ace ace-checkbox-2 children"
                                                                            <?php if($group){ if(in_array($vv['id'],$group['rules'])){echo 'checked="checked"';}}?>
                                                                            type="checkbox" value="{$vv.id}"/>
                                                                            <span class="lbl"> {$vv.name}</span>
                                                                        </label>
                                                                        {notempty name="vv.children"}
                                                                            {volist name="vv.children" id="vvv"}
                                                                                <label class="col-xs-2" style="width:160px;">
                                                                                    <input name="rules[]" class="ace ace-checkbox-2 children"
                                                                                    <?php if($group){ if(in_array($vvv['id'],$group['rules'])){echo 'checked="checked"';}}?>
                                                                                    type="checkbox" value="{$vvv.id}"/>
                                                                                    <span class="lbl"> {$vvv.name}</span>
                                                                                </label>
                                                                            {/volist}
                                                                        {/notempty}
                                                                    {/volist}
                                                                </div>
                                                            </div>
                                                        {/notempty}
                                                    </div>
                                                </div>
                                            {/volist}
                                        </div>
                                    </div>
                                </div>

                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info submit" type="button">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                            <input type="hidden" name="__token__" value="{$Request.token}">
                            <input type="hidden" name="id" id="id" value="{$group.id}">
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--------------------------------底部版权 置顶 start------------------------------------------------------>
    {include file="Public/footer"/}
    <!--------------------------------底部版权 置顶 end-------------------------------------------------------->

</div>

<!--------------------------------------底部JS start----------------------------------------------------------->
{include file="Public/footerjs"/}
<!--------------------------------------底部JS end------------------------------------------------------------->

<script type="text/javascript">
    $(".children").click(function () {
        $(this).parent().parent().parent().parent().find(".father").prop("checked", true);
    })
    $(".father").click(function () {
        if (this.checked) {
            $(this).parent().parent().parent().parent().find(".children").prop("checked", true);
        } else {
            $(this).parent().parent().parent().parent().find(".children").prop("checked", false);
        }
    })
    $(".submit").click(function () {
        var title = $("#name").val();
        if (title == '') {
            bootbox.dialog({
                message: "用户组名称不能为空。",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
        $('#form').submit();

    })
</script>
</body>
</html>
